﻿<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>完善当当购物车页面</title>
    <link type="text/css" rel="stylesheet" href="css/cartStyle.css" />
</head>
<body>

<div class="content">
    <div class="logo">
        <img src="images/dd_logo.jpg"><span>关闭</span>
    </div>
    <div class="cartList">
        <ul>
            <li>¥<input type="text" name="price" value="21.90" id="danjia1"></li>
            <li><input type="button" name="minus" value="-" onclick="jian1()"  />
                <input type="text" name="amount" value="1" id="num1"/>
                <input type="button" name="plus" value="+" onclick="jia1()" /></li>
            <li id="price0">¥21.90</li>
            <li><p>移入收藏</p><p>删除</p></li>
        </ul>
        <ul>
            <li>¥<input type="text" name="price" value="24.00" ></li>
            <li><input type="button" name="minus" value="-" onclick="jian()" >
                <input type="text" name="amount" value="1" id="num">
                <input type="button" name="plus" value="+" onclick="jia()"></li>
            <li id="price1">¥24.00</li>
            <li><p>移入收藏</p><p>删除</p></li>
        </ul>
        <ol>
            <li id="totalPrice">&nbsp;</li>
            <li><span onclick="result()">结 算</span></li>
        </ol>
    </div>
</div>


<script>

    function jia1(){
       num1.value=parseInt(num1.value)+1;
        price0.innerHTML=(parseInt(num1.value)*21.9).toFixed(2);
    }
    function jian1(){
        num1.value= parseInt(num1.value)-1;
        if(num1.value<0){
            num1.value=0;
        }
        price0.innerHTML=(parseInt(num1.value)*21.9).toFixed(2);
    }

    function jia(){
        num.value=parseInt(num.value)+1;
        price1.innerHTML=(parseInt(num.value)*21.9).toFixed(2);
    }
    function jian(){
        num.value= parseInt(num.value)-1;
        if(num.value<0){
            num.value=0;
        }
        price1.innerHTML=(parseInt(num.value)*21.9).toFixed(2);
    }
function result(){
   totalPrice.innerHTML=("￥"+(parseInt((num1.value*21.9).toFixed(2))+parseInt((num.value*21.9).toFixed(2))));
}

</script>

</body>
</html>



